package com.contest.ws;

import org.springframework.web.socket.WebSocketSession;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class WebSocketSessionManager {
    private volatile Map<String,Map<String,List<WebSocketSession>>> sessionMap;
    private volatile Map<String,List<WebSocketSession>> roomSession;
    private static WebSocketSessionManager sessionManager = new WebSocketSessionManager();

    private WebSocketSessionManager(){}

    public static synchronized WebSocketSessionManager getInstance() {
        if(sessionManager == null){
            sessionManager = new WebSocketSessionManager();
        }
            return sessionManager;
    }

    public synchronized Map<String, Map<String, List<WebSocketSession>>> getSessionMap() {
        return sessionMap;
    }

    public void setSessionMap(Map<String, Map<String, List<WebSocketSession>>> sessionMap) {
        this.sessionMap = sessionMap;
    }

    public Map<String, List<WebSocketSession>> getRoomSession(String race) {
        return roomSession;
    }

    public void setRoomSession(Map<String, List<WebSocketSession>> roomSession) {
        this.roomSession = roomSession;
    }
}
